package com.wonders.module.base.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wonders.framework.util.bean.BeanUtil;
import com.wonders.module.base.dao.DicDao;
import com.wonders.module.base.entity.vo.DicVo;
import com.wonders.module.base.service.DicService;

/**
 * 数据字典业务层实现
 * 
 * @author WuBin
 * 
 */
@Service
public class DicServiceImpl implements DicService {

	@Autowired
	private DicDao dicDao;

	public Map<String, List<DicVo>> getDicMap() {
		List<DicVo> dicList = BeanUtil.copyList(dicDao.getDicList(),
				DicVo.class);
		Map<String, List<DicVo>> dicMap = new HashMap<String, List<DicVo>>();
		for (DicVo dic : dicList) {
			List<DicVo> childDicList = dicMap.get(dic.getType());
			if (childDicList == null) {
				childDicList = new ArrayList<DicVo>();
				dicMap.put(dic.getType(), childDicList);
			}
			childDicList.add(dic);
		}
		return dicMap;
	}

}
